"""
    Database service

    -- Create the database and table with the following SQL

    CREATE DATABASE chisheng CHARACTER SET utf8 COLLATE utf8_general_ci;;

    CREATE TABLE t_student(
        id INT PRIMARY KEY AUTO_INCREMENT comment 'identify',
        `name` VARCHAR(20) NOT NULL DEFAULT '' comment 'student name',
        username CHAR(12) NOT NULL DEFAULT '' comment 'student number',
        `password` VARCHAR(16) NOT NULL DEFAULT '' comment 'password of select course'
    ) ENGINE=INNODB DEFAULT CHARSET=utf8 AUTO_INCREMENT=345;
"""

import pymysql

conn = pymysql.connect(
    user='',  # TODO user
    password='',  # TODO password
    host='',  # TODO password
    port=3306,
    database='chisheng'  # TODO database
)


def get_source() -> tuple:
    """
    获取所有的学生数据
    :return: tuple
    """
    cursor = conn.cursor()  # 游标
    cursor.execute("select name, username, password from t_student")
    return cursor.fetchall()
